package com.xiaoshuidi.cloud.module.member.mapper.point;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.xiaoshuidi.cloud.module.member.controller.admin.point.vo.MemberPointChangesPageReqVo;
import com.xiaoshuidi.cloud.module.member.controller.admin.point.vo.MemberPointChangesPageRespVo;
import com.xiaoshuidi.cloud.module.member.controller.app.point.vo.MallPointRecord;
import com.xiaoshuidi.cloud.module.member.controller.app.point.vo.PointsForm;
import com.xiaoshuidi.cloud.module.member.controller.app.point.vo.TenantPointsRecordDto;
import com.xiaoshuidi.cloud.module.member.controller.app.point.vo.TenantPointsRecordVo;
import com.xiaoshuidi.cloud.module.member.pojo.point.MemberPointsRecordEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @description 租客积分记录Mapper层
 * @author neil
 * @date 2022-12-14 18:08:07
 * @version generator
 */
@Mapper
public interface MemberPointsRecordMapper extends BaseMapper<MemberPointsRecordEntity> {
	

    @Select("SELECT  *  FROM  `tenant_points_record`  WHERE  YEAR(created_time) = YEAR(NOW()) and record_type = 4 and tenant_user_id = #{tenantUserId} limit 1")
    TenantPointsRecordDto getBirthDayPointsRecord(@Param("tenantUserId") Long tenantUserId);

    @Select("SELECT  *  FROM  `tenant_points_record`  WHERE record_no = #{recordNo} limit 1")
    TenantPointsRecordDto getPointRecordByRecordNo(@Param("recordNo") String recordNo);

    List<MemberPointChangesPageRespVo> selectPointsChangePage(IPage<MemberPointChangesPageReqVo> page, @Param("reqVo") MemberPointChangesPageReqVo reqVo);

    List<MemberPointChangesPageRespVo> selectPointsChangePage(@Param("reqVo")MemberPointChangesPageReqVo reqVo);

    List<TenantPointsRecordVo> selectTenantPointsRecords(IPage<TenantPointsRecordVo> page, @Param("form")PointsForm form);

    List<MallPointRecord> getMallPointsChangeDetail( IPage<MallPointRecord> page,@Param("userId")Long userId);

    Long getTotalPointsByOldRecord(@Param("oldRecordNo") String oldRecordNo, @Param("userId") Long userId);
}
